home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / Tool Chest / Development Platforms / MPW Related / Universal Interfaces / PPCCIncludes / FCntl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-13  |  4.7 KB  |  183 lines  |  [TEXT/MPS ]

  1. /*
  2.  * FCntl.h -- faccess(), fcntl(), and open() mode flags
  3.  *
  4.  * Portions copyright American Telephone & Telegraph
  5.  * Used with permission, Apple Computer Inc. (1985,1988,1990,1992,1993)
  6.  * All rights reserved.
  7.  *
  8.  * Warning:  This interface is NOT a part of the ANSI C standard.
  9.  *             We do NOT claim to be POSIX compliant.
  10.  *             If you want your code to be portable, don't use this interface.
  11.  */
  12.  
  13. #ifndef __FCNTL__
  14. #define __FCNTL__
  15.  
  16. #ifndef __TYPES__
  17. #include <Types.h>
  18. #endif
  19.  
  20. #ifndef __FILES__
  21. #include <Files.h>
  22. #endif
  23.  
  24. #ifndef __ALIASES__
  25. #include <Aliases.h>
  26. #endif
  27.  
  28. /*
  29.  *    For use by lseek():
  30.  */
  31.  
  32. #ifndef __STDIO__            /* these defns exactly paralled in StdIO.h for fseek() */
  33. #define SEEK_CUR    1
  34. #define SEEK_END    2
  35. #define SEEK_SET    0
  36. #endif
  37.  
  38. /*
  39.  * faccess() commands; for general use
  40.  */
  41.                      /* 'd' => "directory" ops */
  42. #define F_DELETE        (('d'<<8)|0x01)
  43. #define F_RENAME        (('d'<<8)|0x02)
  44.  
  45. /*
  46.  * more faccess() commands; for use only by MPW tools
  47.  */
  48.  
  49. #define F_OPEN             (('d'<<8)|0x00)        /* reserved for operating system use */
  50.                     /* 'e' => "editor" ops */
  51. #define F_GTABINFO         (('e'<<8)|0x00)        /* get tab offset for file */    
  52. #define F_STABINFO         (('e'<<8)|0x01)        /* set     "    "        "    "  */
  53. #define F_GFONTINFO        (('e'<<8)|0x02)        /* get font number and size for file */
  54. #define F_SFONTINFO        (('e'<<8)|0x03)        /* set     "        "    "    "    "    "      */
  55. #define F_GPRINTREC        (('e'<<8)|0x04)        /* get print record for file */
  56. #define F_SPRINTREC        (('e'<<8)|0x05)        /* set     "        "    "    "      */
  57. #define F_GSELINFO         (('e'<<8)|0x06)        /* get selection information for file */
  58. #define F_SSELINFO         (('e'<<8)|0x07)        /* set        "        "        "        " */
  59. #define F_GWININFO         (('e'<<8)|0x08)        /* get current window position */
  60. #define F_SWININFO         (('e'<<8)|0x09)        /* set    "        "        "        */
  61. #define F_GSCROLLINFO    (('e'<<8)|0x0A)        /* get scroll information */
  62. #define F_SSCROLLINFO    (('e'<<8)|0x0B)        /* set    "           "        */
  63. #define F_GMARKER        (('e'<<8)|0x0D)        /* Get Marker */
  64. #define F_SMARKER        (('e'<<8)|0x0C)        /* Set   "       */
  65. #define F_GSAVEONCLOSE    (('e'<<8)|0x0F)        /* Get Save on close */
  66. #define F_SSAVEONCLOSE    (('e'<<8)|0x0E)        /* Set   "     "     "      */
  67.  
  68. /*
  69.  *    argument structure for use with F_SMARKER command
  70.  */
  71. #ifdef powerc
  72. #pragma options align=mac68k
  73. #endif
  74. struct MarkElement {
  75.     int                start;            /* start position of mark */
  76.     int                end;            /* end position */
  77.     unsigned char    charCount;        /* number of chars in mark name */
  78.     char            name[64];        /* first char of mark name */
  79.                                     /* note: typically extra space is allocated */
  80. } ;                                    /*   in back to allow room for a longer string */
  81. #ifdef powerc
  82. #pragma options align=reset
  83. #endif
  84. #ifndef __cplusplus
  85. typedef struct MarkElement MarkElement;
  86. #endif
  87.  
  88. #ifdef powerc
  89. #pragma options align=mac68k
  90. #endif
  91. struct SelectionRecord {
  92.     long    startingPos;
  93.     long    endingPos;
  94.     long    displayTop;
  95. };
  96. #ifdef powerc
  97. #pragma options align=reset
  98. #endif
  99. #ifndef __cplusplus
  100. typedef struct SelectionRecord SelectionRecord;
  101. #endif
  102.  
  103. /*
  104.  * Mode values accessible to open()
  105.  */
  106. #define O_RDONLY         0         /* Bits 0 and 1 are used internally */
  107. #define O_WRONLY         1         /* Values 0..2 are historical */
  108. #define O_RDWR              2        /* NOTE: it goes 0, 1, 2, *!* 8, 16, 32, ... */
  109. #define O_APPEND    (1<< 3)        /* append (writes guaranteed at the end) */
  110. #define O_RSRC         (1<< 4)        /* Open the resource fork */
  111. #define O_ALIAS        (1<< 5)        /* Open alias file */
  112. #define O_CREAT        (1<< 8)        /* Open with file create */
  113. #define O_TRUNC        (1<< 9)        /* Open with truncation */
  114. #define O_EXCL         (1<<10)     /* w/ O_CREAT:  Exclusive "create-only" */
  115. #define O_BINARY    (1<<11)     /* Open as a binary stream */
  116. #define O_NRESOLVE    (1<<14)        /* Don't resolve any aliases */
  117.  
  118. #ifdef __cplusplus
  119. extern "C" {
  120. #endif
  121.  
  122. /*
  123.  *        function prototypes
  124.  */
  125. int  close(int);
  126. int  creat(const char*);
  127. int     dup(int filedes);        /* OBSOLETE: fcntl(filedes, F_DUPFD, 0) is preferred */
  128. int     faccess(char*, unsigned int, long*);
  129. int  fcntl(int, unsigned int, int);
  130. long lseek(int, long, int);
  131. int  open(const char*, int);
  132. int  read(int, char*, unsigned);
  133. int  unlink(char*);
  134. int  write(int, const char*, unsigned);
  135.  
  136. OSErr ResolveFolderAliases (
  137. /* Info in  */
  138.     short volume,
  139.     long directory,
  140.     StringPtr path,
  141.     Boolean resolveLeafName,
  142. /* Info out */
  143.     FSSpec *theSpec,
  144.     Boolean *isFolder,
  145.     Boolean *hadAlias,
  146.     Boolean *leafIsAlias);
  147.  
  148. OSErr MakeResolvedFSSpec (
  149.     short volume,
  150.     long directory,
  151.     StringPtr path,
  152.     FSSpec *theSpec,
  153.     Boolean *isFolder,
  154.     Boolean *hadAlias,
  155.     Boolean *leafIsAlias);
  156.  
  157. OSErr MakeResolvedPath (
  158.     short volume,
  159.     long directory,
  160.     StringPtr path,
  161.     Boolean resolveLeafAlias,
  162.     char *buffer,
  163.     Boolean *isFolder,
  164.     Boolean *hadAlias,
  165.     Boolean *leafIsAlias);
  166.  
  167. OSErr ResolvePath (
  168.     char *rawPath,
  169.     char *resolvedPath,
  170.     Boolean *isFolder,
  171.     Boolean *hadAlias);
  172.  
  173. #ifdef __cplusplus
  174. }
  175. #endif
  176.  
  177. /*
  178.  * fcntl() commands
  179.  */
  180. #define F_DUPFD 0       /* Duplicate files (file descriptor) */
  181.  
  182. #endif    /*    __FCNTL__    */
  183.